package com.example.nbb.Service;

import com.example.nbb.Dao.NewDao;
import com.example.nbb.Entity.ResultEntity;
import jakarta.annotation.Resource;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

@Service
public class NewService {
    private static final Logger logger = LoggerFactory.getLogger(NewService.class);//日志。getLogger需要传入当前的类名

    @Resource
    NewDao newDao;

    /**
     * 获取所有的新闻
     * @return
     */
    public String getAllNew() {
        try {
            return ResultEntity.success(newDao.getAll());
        } catch (Exception e) {
            e.printStackTrace();
            logger.error(e.getLocalizedMessage());
            return ResultEntity.fail(-10004);
        }
    }


}
